<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/6/5
 * Time: 9:12
 */
namespace App\Modules\Jobs\Services;
use App\Modules\Task\Models\TaskHelp;
use Redis;

class UpdateShareService {

    /**
     * 更新用户帮找次数
     * @param $uid
     * @return mixed
     */
    public static function updateUserHelpNum($uid){
        $userHelpNum = Redis::hget('user_share_info:'.$uid,'userHelpNum');
        if($userHelpNum) {

            $userHelpNum++;
        }else{
            $res = TaskHelp::getUserHelpNum($uid);
            $userHelpNum = $res->help_num;
        }
        Redis::hset('user_share_info:'.$uid,'userHelpNum',$userHelpNum);
        return $userHelpNum;
    }

    /**
     * 更新用户帮找成功次数
     * @param $uid
     * @return mixed
     */
    public static function updateUserHelpSucNum($uid) {
        $userHelpNum = Redis::hget('user_share_info:'.$uid,'userHelpSucNum');
        if($userHelpNum) {
            $userHelpNum++;
        }else{
            $res =TaskHelp::getUserHelpSucNum($uid);
            $userHelpNum = $res->help_num;
        }
        Redis::hset('user_share_info:'.$uid,'userHelpSucNum',$userHelpNum);
        return $userHelpNum;
    }
}